package com.aqs;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author xudong
 */
public class LockSupportDemo {

	public static void main(String[] args) throws InterruptedException {

		Thread thread1 = new Thread(() -> {

			System.out.println(Thread.currentThread().getName()  + " 锁定");
			LockSupport.park();
			System.out.println(Thread.currentThread().getName()  + " 解锁");
			System.out.println(Thread.currentThread().getName() + " start");
		}, "thread - 1");

		Thread thread2 = new Thread(() -> {
			System.out.println(Thread.currentThread().getName()  + " 锁定");
			LockSupport.park();

			System.out.println(Thread.currentThread().getName()  + " 解锁");
			System.out.println(Thread.currentThread().getName() + " start");
		},"thread - 2");

		thread1.start();
		thread2.start();

		TimeUnit.SECONDS.sleep(2);
		LockSupport.unpark(thread1);

	}
}
